<template>
  <div class="hello">
    <button class="btn btn-danger">xxx</button>
  <div class="row">
    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">是反对法</div>
    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">是反对法</div>
    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">是反对法</div>
    </div>
<!--    <Upload action="http://120.77.245.11:81/v1/uploadImg" :with-credentials="false">
    <Button type="ghost" icon="ios-cloud-upload-outline">Upload files</Button>
  </Upload>-->
    <input class="file" name="file" type="file" @change="update"/>
  </div>
  </template>

  <script type="text/ecmascript-6">
  import urls from '../common/js/urls';
  import util from '../common/js/util';

  export default {
    name: 'HelloWorld',
    data() {
      return {
        msg: 'Welcome to Your Vue.js App',
        url:urls.base+urls.uploadImg,
        myHeader:{'Content-Type':'multipart/form-data'}
      }
    },
    mounted() {
      /* this.$http({
         method:"post",
         // url:"http://120.77.245.11:81/v1/partner/getUserProfitDetail",
         url:"http://120.77.245.11:81/v1/partner/login",
         /!*params:{
           startTime:"2018-01-16",
           endTime:"2018-01-16",
           token:"b49be5b1daf0bffcb8b735216f6ca28e",
           page:"1"
         }*!/
         data:{
           name:"",
           password:"123456"
         }
       }).then(res=>{
         console.log(res);
       }).catch(res=>{
         console.error(res);
       })*/
      /* console.log(util.get);
       this.$http.post(urls.base+urls.user_login,{
         name:"",
         password:"123456"
       }).then(res=>{
         alert(res.data.errorCode);
         console.log(res);
       }).catch(res=>{
         console.error(res);
       });*/

      /*util.get(this, urls.base + urls.user_income, {
        startTime: "2018-01-16",
        endTime: "2018-01-16",
        token: "b49be5b1daf0bffcb8b735216f6ca28e",
        page: "1"
      }).then(res => {
        // alert(res.data.errorCode);
        console.log(res);
      }).catch(res => {
        console.error(res);
      });
      util.post(this, urls.base + urls.user_login, {
        name: "",
        password: "123456"
      }).then(res => {
        // alert(res.data.errorCode);
        console.log(res);
      }).catch(res => {
        console.error(res);
      });*/
    },
    methods:{
      update(e){
        let file = e.target.files[0];
        let param = new FormData(); //创建form对象
        param.append('file',file,file.name);//通过append向form对象添加数据
        param.append('chunk','0');//添加form表单中其他数据
       /* console.log(param.get('file')); //FormData私有类对象，访问不到，可以通过get判断值是否传进去
        let config = {
          headers:{'Content-Type':'multipart/form-data'}
        };  //添加请求头
        let headers = {'Content-Type':'multipart/form-data'};
        this.$http({
          method:'post',
          url:'http://120.77.245.11:81/v1/uploadImg',
          data:param,
          headers:headers
        }).then(response=>{
            console.log(response.data);
          })*/
        util.post(this,'http://120.77.245.11:81/v1/importTables',param).then(res=>{
          console.log(res);
        });
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1, h2 {
    font-weight: normal;
  }

  ul {
    list-style-type: none;
    padding: 0;
  }

  li {
    display: inline-block;
    margin: 0 10px;
  }

  a {
    color: #42b983;
  }
</style>
